#!/bin/sh -e
#
# zzz-testing
#
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
#
# In order to enable or disable this script just change the execution
# bits.
#
# By default this script does nothing.

BOOTSTRAP_WORK_DIR=/etc/kpc

testing_file="$BOOTSTRAP_WORK_DIR/testing.sh"
testing_bak="${testing_file}_bak"
testing_done="${testing_file}_done"
testing_lock="${testing_file}_lock"

if [ -x $testing_file ]; then
  if [ -f $testing_done ]; then
    mv -f $testing_file $testing_bak
  else
    (flock -x $testing_lock -c "$testing_file")&
  fi
fi

exit 0
